home *** CD-ROM | disk | FTP | other *** search
- { Window31.inc - Multi-level windowing routines ver 3.1, 01-24-87 }
- { }
- { This file allows you to produce quick multi-level windows for IBM PC/XT/AT }
- { compatibles in any column mode (40/80/etc.). You should get a copy of }
- { QWIK21.ARC or a later version to make full use of quick screen writing }
- { utilites. This file has been released under the free Teamware concept. }
- { Editor: Jim H. LeMay (Author of QWIK21.INC and editor of this file) }
- { Author: Michael Burton (Original author of WINDO.INC version 2.3) }
-
- type
- Borders = (none, single, double, mixed, solid, diamond, circle,
- Lhatch, Mhatch, Hhatch);
- BrdrRec = record
- TL,TH,TR,LV,RV,BL,BH,BR: string[1];
- end;
- WndwStatType = record
- Wrow,Wcol,Wrows,Wcols,Wattrib,WBattrib: byte;
- Wbordr: Borders;
- Wlastx,Wlasty: byte;
- end;
- BytePtr = ^byte;
- Str160 = String[160];
- (****************************************************************************)
- (* *)
- (* THE ONLY DIFFERENCE BETWEEN THIS AND WINDOW30.INC IS THE *)
- (* DEFINITION OF SOLID BELOW. THE ORIGINAL SOLID DOES NOT *)
- (* LOOKS GOOD WITH THESE PULLDOWN MENUS (ALTHOUGH IT CAN BE USED) *)
- (****************************************************************************)
-
- const MaxWndw = 30; { Total number of windows on screen at any time }
- brdr: array [none..Hhatch] of BrdrRec =
- ((TL:' ';TH:' ';TR:' ';LV:' ';RV:' ';BL:' ';BH:' ';BR:' '), { none }
- (TL:'┌';TH:'─';TR:'┐';LV:'│';RV:'│';BL:'└';BH:'─';BR:'┘'), { single }
- (TL:'╔';TH:'═';TR:'╗';LV:'║';RV:'║';BL:'╚';BH:'═';BR:'╝'), { double }
- (TL:'╒';TH:'═';TR:'╕';LV:'│';RV:'│';BL:'╘';BH:'═';BR:'╛'), { mixed }
- (TL:'▐';TH:'▀';TR:'▌';LV:'▐';RV:'▌';BL:'▐';BH:'▄';BR:'▌'), { solid }
- (TL:#8 ;TH:#8 ;TR:#8 ;LV:#8 ;RV:#8 ;BL:#8 ;BH:#8 ;BR:#8 ), { diamond}
- (TL:#10;TH:#10;TR:#10;LV:#10;RV:#10;BL:#10;BH:#10;BR:#10), { circle }
- (TL:'░';TH:'░';TR:'░';LV:'░';RV:'░';BL:'░';BH:'░';BR:'░'), { Lhatch }
- (TL:'▒';TH:'▒';TR:'▒';LV:'▒';RV:'▒';BL:'▒';BH:'▒';BR:'▒'), { Mhatch }
- (TL:'▓';TH:'▓';TR:'▓';LV:'▓';RV:'▓';BL:'▓';BH:'▓';BR:'▓')); { Hhatch }
-
- var
- WndwStat : Array [0..MaxWndw] of WndwStatType; { window stats }
- WndwPtr : Array [1..MaxWndw] of BytePtr; { pointer to window on heap }
- LI : byte; { level index }
- Tattr: byte absolute Dseg:$0008; { Turbo's attribute value }
- Battr: byte; { Border attribute }
-
- { =========================================================================== }
- { NAME: Qbox ver 3.0, 01-01-87 }
- { DESCRIPTION: Writes a window with optional border. Since attribute }
- { is byte, the colors should always be specified. }
- { PARAMETERS: See QWIK21.DOC }
- { =========================================================================== }
- procedure Qbox (Row,Col,Rows,Cols,WndwAttr,BrdrAttr: byte; BrdrSel: Borders);
- begin
- if (Rows>=2) and (Cols>=2) then
- begin
- with Brdr[BrdrSel] do
- begin
- QwriteV (Row ,Col ,BrdrAttr,TL);
- Qfill (Row ,Col+1 ,1 ,Cols-2,BrdrAttr,TH);
- QwriteV (Row ,Col+Cols-1 ,BrdrAttr,TR);
- Qfill (Row+1 ,Col ,Rows-2,1 ,BrdrAttr,LV);
- Qfill (Row+1 ,Col+Cols-1,Rows-2,1 ,BrdrAttr,RV);
- QwriteV (Row+Rows-1,Col ,BrdrAttr,BL);
- Qfill (Row+Rows-1,Col+1 ,1 ,Cols-2,BrdrAttr,BH);
- QwriteV (Row+Rows-1,Col+Cols-1 ,BrdrAttr,BR);
- Qfill (Row+1 ,Col+1 ,Rows-2,Cols-2,WndwAttr,' ')
- end
- end
- end;
-
- { =========================================================================== }
- { NAME: Bleep ver 1.0, 01-12-86 }
- { DESCRIPTION: Produces a bleeping sound times number of times }
- { PARAMETERS: Times - The number of bleeps required }
- { =========================================================================== }
- procedure Bleep (Times: byte);
- var i : byte;
- begin
- for i := 1 to Times do
- begin
- NoSound;
- Sound (880);
- Delay ( 60);
- Sound (440);
- Delay ( 60);
- NoSound;
- end;
- end;
-
- { =========================================================================== }
- { NAME: InitWindow }
- { DESCRIPTION: Initializes the window variables. Use this routine before }
- { using MakeWindow, RemoveWindow or TitleWindow }
- { PARAMETERS: }
- { TxtColor - Starting text color }
- { TxtBack - Starting background color }
- { =========================================================================== }
- procedure InitWindow (TxtColor,TxtBack: byte);
- begin
- Qinit;
- TextColor (TxtColor);
- TextBackground (TxtBack);
- with WndwStat[0] do
- begin
- Wrow := 1; { Initialize non-window zero }
- Wcol := 1;
- Wrows := 25;
- Wcols := 80;
- Wattrib := Tattr;
- WBattrib := Tattr;
- Wbordr := none;
- Wlastx := Wherex;
- Wlasty := Wherey
- end;
- LI := 0;
- Qfill ( 1, 1,25,80,Tattr,' ');
- End;
-
- { =========================================================================== }
- { NAME: MakeWindow ver 3.0, 01-01-87 }
- { DESCRIPTION: Creates a window on your screen. }
- { PARAMETERS: }
- { Row - First row (1 - Screen limit) }
- { Col - First column (1 - Screen limit) }
- { Rows - # of rows (1 - Screen limit) }
- { Cols - # of columns (1 - Screen limit) }
- { Tcolor - Text color (0 - 15) }
- { Tback - Text background (0 - 7, > 7 for blinking) }
- { Bcolor - Border color (0 - 15) }
- { Bback - Border backgrnd (0 - 7, > 7 for blinking) }
- { BrdSel - Border selection (none - Hhatch) }
- { =========================================================================== }
- procedure MakeWindow (Row,Col,Rows,Cols,Tcolor,Tback,Bcolor,Bback: byte;
- BrdrSel: Borders);
- var wsize: integer;
- begin
- if LI >= MaxWndw then
- begin
- WriteLn('Too many Windows!');
- Bleep(4)
- end
- else
- begin
- wsize := (Rows*Cols) shl 1; { Memory size needed to store display }
- If (0<memavail) and (memavail<=(wsize shr 4)) then
- { if memavail<0 then there's plenty of room (>512kb)}
- begin
- WriteLn('Not enough Heap space!');
- Bleep(4);
- end
- else
- begin
- WndwStat[LI].Wlastx := Wherex; { Store old cursor coordinates }
- WndwStat[LI].Wlasty := Wherey;
- LI := LI + 1; { Go to next window level }
- TextColor (Tcolor);
- TextBackground (Tback);
- Battr:= Bback shl 4 + Bcolor;
- with WndwStat[LI] do
- begin
- Wrow := Row; { Store all variables for this window }
- Wcol := Col;
- Wrows := Rows;
- Wcols := Cols;
- Wattrib := Tattr;
- Wbordr := BrdrSel;
- WBattrib := Battr
- end;
- GetMem (WndwPtr[LI],wsize); { Get enough heap to store old display }
- QstoreToMem (Row,Col,Rows,Cols,WndwPtr[LI]^);
- Qbox (Row,Col,Rows,Cols,Tattr,Battr,BrdrSel);
- if BrdrSel=none then Window (Col,Row,Col+Cols-1,Row+Rows-1)
- else Window (Col+1,Row+1,Col+Cols-2,Row+Rows-2);
- GotoXY (1,1);
- end;
- end;
- end;
-
- { =========================================================================== }
- { NAME: RemoveWindow ver 3.0, 01-01-87 }
- { DESCRIPTION: Remove the last window created from the screen. To }
- { get back to the original screen, there must be as many }
- { RemoveWindow(s) as there are MakeWindow(s). }
- { =========================================================================== }
- procedure RemoveWindow;
- var wsize: integer;
- begin
- if LI = 0 then
- begin
- WriteLn ('No Window To Remove!');
- Bleep (4);
- end
- else
- begin
- with WndwStat[LI] do
- begin
- QstoreToScr (Wrow,Wcol,Wrows,Wcols,WndwPtr[LI]^);
- FreeMem (WndwPtr[LI],Wrows*Wcols shl 1); { Release heap space }
- end;
- LI := LI - 1; { Go to next lower level }
- with WndwStat[LI] do
- begin
- Tattr:= Wattrib;
- if Wbordr = none then Window (Wcol,Wrow,Wcol+Wcols-1,Wrow+Wrows-1)
- else Window (Wcol+1,Wrow+1,Wcol+Wcols-2,Wrow+Wrows-2);
- GotoXY (Wlastx,Wlasty);
- end;
- End;
- End;
-
- { =========================================================================== }
- { NAME: TitleWindow ver 3.0, 01-01-87 }
- { DESCRIPTION: Places a centered title in the top border of a window }
- { PARAMETERS: Title - Optional title of the window }
- { =========================================================================== }
- procedure TitleWindow (title: Str160);
- begin
- with WndwStat[LI] do
- begin
- QwriteCV (Wrow,Wcol,Wcol+Wcols-1, -1,title);
- end
- end;